﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Collections.Generic;
using Itop.YHPC.Model;
using Itop.YHPC.controller;

namespace Itop.YHPC.workflow
{
    public partial class workflow_org_ajax : AjaxPage<yhpcOrg>
    {
        protected override IList<yhpcOrg> onRead()
        {
            string type = Request.QueryString["type"];
            string wfid = Request.QueryString["wfid"];
            string search = Request.QueryString["search"];
            IList<yhpcOrg> list=null;
            if (type == "org") {
                if(wfid=="101")
                    list = workflowController.GetOrgList(" where parentid='root' order by orderid");
                else
                    list = workflowController.GetOrgList(" where dwtype='二级单位' order by orderid");
            } else if (type == "owner")
                list = workflowController.GetOrgList(" where dwtype='二级单位' group by owner");
            else if (type == "gsbm")
                list = workflowController.GetOrgList(" where dwtype='公司部门'  order by orderid");
            if (!string.IsNullOrEmpty(search))
            {
                yhpcOrg org = new yhpcOrg();
                org.id = Guid.NewGuid().ToString();
                org.dwName = "全部";
                list.Insert(0, org);
            }
            return list;

        }
    }
}
